Code Smell: Primitive Obsession

Imagine you’re using a television remote that’s been stripped of its buttons. You want to change channels, but now you need to remember where the numbers were on the remote. Additionally, you need to understand how to interact with a buttonless remote to select a number. Your desire to simply change channels is greatly inconvenienced […]

Code Smell: Temporal Coupling

Have you ever had a bug that was caused by calling commands in the wrong order? Take the following for example: In this example, you can imagine I’m at an arcade with a game card filled up with points that I can use to play games. When I insert the card into different games, the […]

What’s in a Name

Naming is one of the greatest challenges in software. There’s even a quote by Phil Karlton around that idea, as follows: “There are only two hard things in computer science: cache invalidation and naming things.” What makes naming so hard? To answer this, it’s important to understand that a piece of software is really just a translation […]

Swift

It’s been about two years since Apple came out with Swift, which they call a protocol-oriented language. Since then, articles (and a StackOverflow question) have emerged explaining the difference between object-orientation and protocol-orientation. A few examples of these articles are as follows: Is Protocol Oriented Swift Better than Object Oriented Swift? If you’re subclassing, you’re doing […]

Role-playing

The sniper lies in the bushes poised with his finger resting calmly on the trigger. He scans the environment, analyzing his enemy’s movement. He peers through the scope, marks his target, exhales, and pulls the trigger. Paint splatters the victim’s chest, and the referee signals to him that he’s been struck out. A paintball game typically consists […]

OO: Then and Now

Previously, I introduced the foundation of object-orientation: messaging, encapsulation, and late-binding. While messaging is key, it wouldn’t be complete without an understanding of how it works in conjunction with the other two concepts. Understanding the kind of thinking that lead to the creation of object-orientation should assist in this cause. The thinking behind object-orientation is actually based on the recursive idea “that everything […]

And for our next trick: Normality

When I was in elementary school, I sat in the front row of a Lance Burton magic show. It was quite entertaining, and I, along with the rest of the audience, was amazed at the magic tricks he performed. At one point in the show, he looked around for a kid, spotted me, and asked if […]

Mutant Bug

“Captain. I have a visual.” “What’s the status?” “Just one mutant bug, sir.” “Ha! What can one bug do to our company? Destroy it.” A tank round was fired in the bug’s direction. “Good shot. Continue onward.” “Wait, captain. Something doesn’t seem right.” “What’s the matter?” “The bug…it’s spawning more bugs! There seems to be […]